import java.util.Arrays;
import java.util.Random;

public class TimeTest {
   //顺序
    public static int[] order(int[] array){
        for (int i = 0; i < array.length ; i++) {
            array[i]=i;
        }
        return array;
    }
    //逆序
    public static int[] reverseOrder(int[] array){
        for (int i = 0; i <array.length ; i++) {
            array[i]=array.length-i;
        }
        return array;
    }
    //随机顺序
    public static int[] randomOrderNum(int[] array){
        Random random=new Random();
        for (int i = 0; i < array.length ; i++) {
            array[i]=random.nextInt(10_0000);
            array[i]=random.nextInt(1_0000);
        }
        return array;
    }
    public static void insertSortTime(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        MySort.insertSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }

    public static void main1(String[] args) {
        int[] array=new int[1_0000];
        System.out.println("排序顺序的耗时：");
        insertSortTime(order(array));
        System.out.println("排序顺序的耗时：");
        insertSortTime(reverseOrder(array));
        System.out.println("排序顺序的耗时：");
        insertSortTime(randomOrderNum(array));
    }
    public static void shellSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        MySort.shellSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }

    public static void main2(String[] args) {
        int[] array=new int[1_0000];
        System.out.println("排序顺序的耗时：");
       shellSort(order(array));
        System.out.println("排序顺序的耗时：");
        shellSort(reverseOrder(array));
        System.out.println("排序顺序的耗时：");
       shellSort(randomOrderNum(array));
    }
    public static void selectSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        MySort.selectSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }

    public static void main3(String[] args) {
        int[] array=new int[1_0000];
        System.out.println("排序顺序的耗时：");
        selectSort(order(array));
        System.out.println("排序顺序的耗时：");
        selectSort(reverseOrder(array));
        System.out.println("排序顺序的耗时：");
       selectSort(randomOrderNum(array));
    }
    public static void  heapSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        MySort.heapSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }

    public static void main4(String[] args) {
        int[] array=new int[1_0000];
        System.out.println("排序顺序的耗时：");
        heapSort(order(array));
        System.out.println("排序顺序的耗时：");
        heapSort(reverseOrder(array));
        System.out.println("排序顺序的耗时：");
        heapSort(randomOrderNum(array));
    }
    public static void  bubbleSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        MySort.bubbleSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }

    public static void main5(String[] args) {

        int[] array=new int[1_0000];
        System.out.println("排序顺序的耗时：");
        bubbleSort(order(array));
        System.out.println("排序顺序的耗时：");
        bubbleSort(reverseOrder(array));
        System.out.println("排序顺序的耗时：");
        bubbleSort(randomOrderNum(array));
    }
    public static void  quickSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        MySort.quickSort(array);
        long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }

    public static void main6(String[] args) {
        int[] array=new int[1_0000];
        System.out.println("排序顺序的耗时：");
        quickSort(order(array));
        System.out.println("排序顺序的耗时：");
        quickSort(reverseOrder(array));
        System.out.println("排序顺序的耗时：");
        quickSort(randomOrderNum(array));
    }
    public static void  quickDigPit(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        MySort.quickSortDigPit(array);
        long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }

    public static void main7(String[] args) {
        int[] array=new int[1_0000];
        System.out.println("排序顺序的耗时：");
        quickDigPit(order(array));
        System.out.println("排序顺序的耗时：");
        quickDigPit(reverseOrder(array));
        System.out.println("排序顺序的耗时：");
        quickDigPit(randomOrderNum(array));
    }
    public static void  quickInsertSortDigPit(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        MySort.quickInsertSortDigPit(array);
        long endTime=System.currentTimeMillis();
        System.out.println(endTime-startTime);
    }

    public static void main(String[] args) {
        int[] array=new int[1_0000];
        System.out.println("排序顺序的耗时：");
        quickInsertSortDigPit(order(array));
        System.out.println("排序顺序的耗时：");
       quickInsertSortDigPit(reverseOrder(array));
        System.out.println("排序顺序的耗时：");
        quickInsertSortDigPit(randomOrderNum(array));
    }

}
